﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace AliveCard {
public class RoomTriggerDetector : MonoBehaviour {
    public Room room = null;
    bool m_isEnable = true;

    public bool IsEnable {
        set { m_isEnable = value; }
        get { return m_isEnable; }
    }
    public void OnTriggerEnter2D(Collider2D col) {
        if (m_isEnable == false) return;
        DebugUtil.LogFormat("Room[{0}] Enter. trigger by [{1}]", room.name, col.name);
        ACPuppet p = col.GetComponent<ACPuppet>();
        if(p != null) {
            room.OnEnterRoom(p);
        }
    }
    public void OnTriggerExit2D(Collider2D col) {
        if (m_isEnable == false) return;
        DebugUtil.LogFormat("Room[{0}] Exit. trigger by [{1}]", room.name, col.name);
        ACPuppet p = col.GetComponent<ACPuppet>();
        if(p != null) {
            room.OnExitRoom(p);
        }
    }
}
}